package com.geeker.module.sys.user.controller;

import com.geeker.common.api.CommonResult;
import com.geeker.module.sys.user.dto.LoginDto;
import com.geeker.module.sys.user.sevice.AdminService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Tag(name  = "后台用户管理")
@RequestMapping("/admin")
public class AdminController {

    @Autowired
    private AdminService adminService;

    @Operation(summary = "登录")
    @PostMapping(value = "/login")
    public CommonResult<String> login(@RequestBody @Valid LoginDto dto) {
        String token = adminService.login(dto);
        return CommonResult.success(token);
    }

    @Operation(summary = "退出登录")
    @PostMapping(value = "/logout")
    public CommonResult logout() {
        adminService.logout();
        return CommonResult.success();
    }
}
